#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define ull unsigned long long
#define nl "\n"
#define vi vector<int>
#define vvi vector<vi>
#define vl vector<ll>
#define vvl vector<vl>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define setbits(x) __builtin_popcount(x)
#define zerobits(x) __builtin_ctzll(x)
#define all(a) (a).begin(), (a).end()
#define allr(a) (a).rbegin(), (a).rend()
#define ps(num, pre) fixed << setprecision(pre) << num
#define py cout << "Yes" << nl;
#define pn cout << "No" << nl;
ll mod = 1e9 + 7;
void ans1(bool x)
{
if (x)
cout << "Yes" << nl;
else
cout << "No" << nl;
}
ll power(ll a, ll b, ll m)
{
a %= m;
if (a == 0)
return 0;
ll res = 1;
while (b > 0)
{
if (b & 1)
res = (res * a) % m;
a = (a * a) % m;
b >>= 1;
}
return res;
}
///////////////////////////////////////Working Area///////////////////////////////////////
void solve()
{
// Check Constrains. Do you need to take long long insteed of int?
// Go and check Bold statements
int n;
cin >> n;
string a, b;
cin >> a >> b;
ll equal = 1, less = 1, greater = 1;
ll cnt = 0;
for (int i = 0; i < n; i++)
{
if (a[i] == '?' && b[i] == '?')
{
cnt += 2;
equal = (equal * 10) % mod;
greater = (greater * 55) % mod;
less = (less * 55) % mod;
}
else if (a[i] == '?')
{
cnt++;
int y = b[i] - '0';
greater = (greater * (10 - y)) % mod;
less = (less * (y + 1)) % mod;
}
else if (b[i] == '?')
{
cnt++;
int x = a[i] - '0';
greater = (greater * (x + 1)) % mod;
less = (less * (10 - x)) % mod;
}
else
{
int x = a[i] - '0', y = b[i] - '0';
if (x > y)
{
equal = 0;
less = 0;
}
else if (x < y)
{
equal = 0;
greater = 0;
}
}
}
cout << (power(10, cnt, mod) + equal - less - greater + 3 * mod) % mod << endl;
}
////////////////////////////////////////////////////////////////////////////////////////
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
// int t;
// cin >> t;
// for (int i = 0; i < t; i++)
solve();
return 0;
}
165B - Burning Midnight Oil | 17A - Noldbach problem |
1350A - Orac and Factors | 1373A - Donut Shops |
26A - Almost Prime | 1656E - Equal Tree Sums |
1656B - Subtract Operation | 1656A - Good Pairs |
1367A - Short Substrings | 87A - Trains |
664A - Complicated GCD | 1635D - Infinite Set |
1462A - Favorite Sequence | 1445B - Elimination |
1656C - Make Equal With Mod | 567A - Lineland Mail |
1553A - Digits Sum | 1359B - New Theatre Square |
766A - Mahmoud and Longest Uncommon Subsequence | 701B - Cells Not Under Attack |
702A - Maximum Increase | 1656D - K-good |
1426A - Floor Number | 876A - Trip For Meal |
1326B - Maximums | 1635C - Differential Sorting |
961A - Tetris | 1635B - Avoid Local Maximums |
20A - BerOS file system | 1637A - Sorting Parts |